#ifndef ZTBOXPLUGINLOADER_H
#define ZTBOXPLUGINLOADER_H

#include <QDir>
#include <QObject>

#include "ztbox.h"

class ZTBoxPluginLoader : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QList<ZTBoxInterface*> plugins READ plugins NOTIFY pluginsChanged)
    explicit ZTBoxPluginLoader(QObject *parent = nullptr);
public:
    static ZTBoxPluginLoader& instance();

    void pluginLoader(QString path = "");

    ZTBoxInterface *loadPluginFile(const QString &pluginFilePath, bool skipAppend = false);

    void loadPluginDir(QDir pluginDir);
    void loadPluginDirPath(QString pluginDirPath);

    QList<ZTBoxInterface*> plugins() const;
    void appendPlugins(ZTBoxInterface *newPlugin);

signals:
    void pluginsChanged(ZTBoxInterface* plugin);
    void pluginLoadedSignal(QList<ZTBoxInterface*>);
    void pluginSwitchSignal(const QString &filePath);

private:
    bool loadable = false;
    QList<ZTBoxInterface*> m_plugins;
};

#endif // ZTBOXPLUGINLOADER_H
